<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app"></div>
</body>
<script>
    //5、拷贝继承(把父类的原型中的所有内容复制到子类的原型中)
  function Person(a, b) {
    this.a = a
    this.b = b
  }
  Person.prototype.head = 1
  Person.prototype.foot = 2
  Person.prototype.favColor = ['red', 'green', 'yellow']
  Person.prototype.sayColor = function() {
    alert("喜欢的颜色有：" + this.favColor)
  }

  function Student(id, name) {
    Person.call(this, 20, 30)
    this.id = id
    this.name = name
    this.show = function() {
      return "{id=" + this.id + ",name=" + this.name + ",foot=" + this.foot + ",head=" + this.head + "}"
    }
  }
  //把Person.prototype对象的内容复制到Student.prototype中
  Object.assign(Student.prototype, Person.prototype, {
    gender: "男"
  })
  let stu = new Student(1, "tom")
  console.log(stu.__proto__)
  console.log(stu.gender)
  console.log("stu.a=" + stu.a)
  console.log("stu.b=" + stu.b)
  stu.favColor.push('blue')
  stu.sayColor()
  app.innerHTML = stu.show()
</script>
</html>